package com.hgl.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBHelper {
	private static final String Driver="com.mysql.jdbc.Driver";
	private static final String URl="jdbc:mysql://localhost:3306/hgl";
	private static final String USERNAME="root";
	private static final String PASSWORD="123123";
	
	static{
		try {
			Class.forName(Driver);
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public Connection getConn(){
		Connection conn=null;
		
		try {
			conn=DriverManager.getConnection(URl, USERNAME, PASSWORD);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return conn;
	}
	public void close(Connection conn,PreparedStatement ps){
			try {
				if(conn!=null){
					conn.close();
				}
				if(ps!=null){
					ps.close();
				}
				
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
    
}
